package com.sfh.cp.widget;

import android.content.Context;
import android.graphics.Color;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.sfh.cp.R;

/**
 * 标签样式控件
 */

public class WidgetLabelLayout extends LinearLayout {


    TextView tvTitle;
    TextView tvData;

    public WidgetLabelLayout(Context context) {
        super(context);
        this.init();
    }

    public WidgetLabelLayout(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        this.init();
    }

    public WidgetLabelLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.init();
    }

    private void init() {
        inflate(this.getContext(), R.layout.widget_label_size_layout, this);
        this.tvData = this.find(R.id.tvData);
        this.tvTitle = this.find(R.id.tvTitle);
    }

    private <T> T find(int r) {
        return (T) findViewById(r);
    }


    /***
     * 设置数据 ->财样式
     */
    public void setStyleWealth( String size)
    {
        this.tvTitle.setText("财");
        this.tvTitle.setBackgroundResource(R.drawable.shape4);
        this.tvData.setBackgroundResource(R.drawable.shape1);
        this.tvData.setTextColor(Color.parseColor("#FFD700"));
        this.tvData.setText(size);
    }

    /***
     * 设置数据 ->魅力样式
     */
    public void setStyleCharm(String size)
    {
        this.tvTitle.setText("魅");
        this.tvTitle.setBackgroundResource(R.drawable.shape3);
        this.tvData.setBackgroundResource(R.drawable.shape2);
        this.tvData.setTextColor(Color.parseColor("#FF6EB4"));
        this.tvData.setText(size);
    }
}
